package com.ftg.learn.chapter03;

/**
 * @author kangjx
 * @createTime 2022/6/29
 */
public class Elephant implements Comparable<Elephant> {

    private String name;

    //开闭原则

    private int weight;

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getName() {

        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString(){
        return "{name="+this.getName()+",weight="+this.getWeight()+"}";
    }


    @Override
    public int compareTo(Elephant o) {
        return this.getWeight() - o.getWeight();
    }
}
